function a(a) {
    return !(a = a.split("/"))[a.length - 1] || 46 != a[a.length - 1] && 64 != a[a.length - 1] && 96 != a[a.length - 1] && 132 != a[a.length - 1] || (a[a.length - 1] = 0), 
    a = a.join("/");
}

var e = getApp();

Page({
    data: {
        bgPic: null,
        picChoosed: !1,
        ad: {}
    },
    checkImg(a){
       return e.checkImg(a)
    },
    async assignPicChoosed (head) {
        this.setData({
            picChoosed: !1
        });
        console.log(head)
        // if(!head){
            let a = await this.checkImg(this.data.bgPic)
            console.log(a)
            if(!a||a.result.errCode!==0){
                wx.showModal({
                confirmText: '确定',
                content: '图片内容不合法，请重新选择',
                showCancel: false
                })
                return
            }
        // }
       this.setData({
            picChoosed: !0
        })
    },
    bindGetUserInfo: function(t) {
        this.getRandomAd()
        console.log(t.detail.userInfo), t.detail.userInfo && (e.globalData.userInfo = t.detail.userInfo, 
        console.log(t.detail), this.setData({
            userInfo: t.detail.userInfo,
            bgPic: a(t.detail.userInfo.avatarUrl)
        }), this.assignPicChoosed(true));
    },
    chooseImage: function(a) {
        var e = this;
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ a.target.dataset.way ],
            success: function(a) {
                var t = a.tempFilePaths;
                e.setData({
                    bgPic: t[0]
                }), e.assignPicChoosed();
            },
            fail: function(a) {
                e.assignPicChoosed();
            },
            complete: function(a) {
                e.assignPicChoosed();
            }
        });
    },
    nextPage: function() {
        e.globalData.bgPic = this.data.bgPic, wx.navigateTo({
            url: "../imageeditor/imageeditor"
        });
    },
    onShow(){
        this.getRandomAd()
        getApp().chaping()
    },
    onLoad: function(a) {
        getApp().getRandomAd(true,this)
        this.getRandomAd(true)
    },
    onShareAppMessage: function() {
        return {
            title: "口罩头像-图片编辑助手",
            path: "pages/mask/index/index"
        };
    }
});